#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 110;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m; cin >> n >> m;
	queue<int> q;
	for (int i = 1; i <= n; i++) q.push(i);
	int now = 1;
	while (!q.empty()) {
		if (now == m) {
			cout << q.front() << " ";
			q.pop();
			now = 1;
		}
		else {
			now++;
			q.push(q.front());
			q.pop();
		}
	}
	return 0;
}